Skip to content

Fix particle ID counter in writing checkpoint#199

Merged
haykh merged 1 commit intoentity-toolkit:1.4.0rcfrom
xwgong01:fix/tracking_ckpt
Apr 22, 2026
Merged

Fix particle ID counter in writing checkpoint#199
haykh merged 1 commit intoentity-toolkit:1.4.0rcfrom
xwgong01:fix/tracking_ckpt

Conversation

@xwgong01
Copy link
Copy Markdown
Contributor

Bug description

When writing checkpoint with particle tracking enabled, the particle counter is mistakenly saved with npart() (ln. 641-646 of framework/containers/particles_io.cpp)

out::WriteVariable<npart_t>(io,
                                writer,
                                fmt::format("s%d_counter", index()),
                                npart(),
                                domains_total,
                                domains_offset);

So the counter in the checkpoint is the number of active particles in the domain, which is not equal to the true counter. As a result multiple particles will have the same ID after restarting from checkpoint.

Suggested fix

Substituting npart() with counter().

The fix is tested on 2D shock setup with tracking enabled.

@haykh haykh changed the base branch from master to 1.4.0rc April 22, 2026 20:04
@haykh haykh merged commit 2838547 into entity-toolkit:1.4.0rc Apr 22, 2026
@haykh haykh mentioned this pull request Apr 22, 2026
43 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants